package com.panopset.refactorsf;

import javax.swing.JComponent;

import com.panopset.sf.Windoc;

public abstract class PanNoBorderField<T extends JComponent> extends Field {

    @Override
    protected abstract boolean isValid(final String valueToCheck);

    /**
     * Tool tip text.
     */
    protected final String ptoolTipText;

    /**
     * @param defaultValue
     *            Default value.
     *
     */
    public PanNoBorderField(final Windoc wd, final String defaultValue, 
    		final String toolTipText, final String key) {
        super(wd, defaultValue, key);
        ptoolTipText = toolTipText;
    }

    /**
     * @return Inner component.
     */
    protected abstract T createComponent();

    /**
     * Inner component gui.
     */
    private T gui;

    /**
     * @return inner component.
     */
    public final T getInnerComponent() {
        if (gui == null) {
            gui = createComponent();
            gui.setToolTipText(ptoolTipText);
        }
        return gui;
    }

    public final JComponent getGui() {
    	return getInnerComponent();
    }
}
